package com.hackordie.commons.hardware.components;

import com.hackordie.constants.EComponentsType;

public class Processor extends AComponent {

    private int totalCapacity;
    private int speedForCore;  /** cada core tendra su velocidad individual, con una penalizacion a la speed   */
    private int cores;

    public Processor(String componentName, int energyToTurOn,
            int totalCapacity, int cores, int levelSkill) {
        super(componentName, EComponentsType.Processor, energyToTurOn);

        this.cores = cores;
        
        if (cores > 1) {
            this.speedForCore = totalCapacity - ( (cores % 100) * (100 - levelSkill)); //TODO revisar formulas
        } else {
            this.speedForCore = totalCapacity;
        }
        
        totalCapacity = speedForCore * cores;
    }

    // getters and setters
    public int getTotalCapacity() {
        return speedForCore;
    }
    
    public int getCores() {
        return cores;
    }

    public void setCores(int cores, int levelSkill) {
        this.cores = cores;
        
        if (cores > 1) {
            this.speedForCore = totalCapacity - ((cores % 100) * (100 - levelSkill)); //TODO revisar formulas
        } else {
            this.speedForCore = totalCapacity;
        }
        
        setSpeedForCore(speedForCore);
    }
    
    public void setSpeedForCore(int speedForCore) {
        this.speedForCore = speedForCore;
        totalCapacity = speedForCore * cores;
    }

}
